package com.songcha.library_common.util

import android.content.Context
import java.io.BufferedReader
import java.io.InputStreamReader

class AssetsUtil {
    companion object{
        @JvmStatic
        fun readAssetsString(context: Context, fileName:String):String?{
            var br: BufferedReader? = null
            try {
                br = BufferedReader(InputStreamReader(context.resources.assets.open(fileName)))
                var line: String? = null
                val sb = StringBuilder()
                while (br.readLine().also { line = it } != null){
                    sb.append(line)
                }
                br.close()
                var json = sb.toString()
                return json
            } catch (e: Exception) {
                e.printStackTrace()
            }finally {
                br?.close()
            }
            return null
        }

    }
}